package com.cswangdao.controller.user;


import com.cswangdao.result.Result;
import com.cswangdao.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping ("/wx/auth")
@Slf4j
public class WxAuthController {

    @Autowired
    private UserService userService;

    @PostMapping ("/login")
    public Result login(@RequestBody Map map){
        String username = map.get("username").toString();
        String password = map.get("password").toString();
        log.info("用户登录：username:{},password:{}",username,password);
        Map<String,Object> resMap =userService.login(username,password);
        return Result.success(resMap);
    }

    @PostMapping("/logout")
    public Result logout(){
        SecurityUtils.getSubject().logout();
        return Result.success();
    }
}
